package de.tabuma.lib.contentmanagement;
import de.tabuma.lib.cm.crud.RemoveControllerFacade;
import de.tabuma.lib.cm.crud.ListControllerFacade;
import de.tabuma.lib.cm.crud.CreateControllerFacade;
import de.tabuma.lib.cm.crud.UpdateControllerFacade;
import de.tabuma.lib.contentmanagement.entity.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.logging.*;
/**
 *
 * @author alefen
 */
public class ControllerFacade {

    private static final Logger log = Logger.getLogger(ControllerFacade.class.getName());
    public static void controller(Content content, HttpServletRequest request) {
        if(content==null) {
            return;
        }

        String nav = request.getParameter(content.GeneralContent.getParamName());

        if(nav==null) {
            nav = "" + constants.TYPE_LIST;
        }
        
        int navId = Integer.valueOf(nav).intValue();
        
        //Controlling machanism
        switch(navId) {
            case constants.CREATE:
                de.tabuma.lib.cm.crud.CreateControllerFacade.controller(content, request);
                break;
            case constants.REMOVE:
                de.tabuma.lib.cm.crud.RemoveControllerFacade.controller(content, request);
                break;
            case constants.UPDATE:
                de.tabuma.lib.cm.crud.UpdateControllerFacade.controller(content, request);
                break;
            default:
                de.tabuma.lib.cm.crud.ListControllerFacade.controller(content, request);
                break;
        }
    }
}